package com.opgea.crm.domain.entities;

import com.opgea.crm.common.constant.ApplicationConstant;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.opgea.crm.domain.entities.security.CrmUser;

@Entity
@Table(name="task")
public class Task implements Serializable{
	
	@Id
	@GeneratedValue
	@Column(name="id")
	private Long id;
	@Column(name="name")
	private String taskName;
	@Column(name="details")
	private String taskDetail;
	@ManyToOne
	@JoinColumn(name="project_id")
	private ProjectDetails projectId;
	@ManyToOne
	@JoinColumn(name="priority_id")
	private SetupsValue priorityId;
	@Column(name="milestone")
	private Boolean mileStone;
	
	//@Temporal(TemporalType.TIME)
	@Column(name="estm_duration")
	private Integer estmDuration;
	
	@Enumerated(EnumType.STRING)
	@Column(name="duration_unit")
	private ApplicationConstant.TaskdurationUnit durationUnit;
	
	@Temporal(TemporalType.DATE)
	@Column(name="estm_startdt")
	private Date estmStarDate;
	@Temporal(TemporalType.DATE)
	@Column(name="estm_endtd")
	private Date estmEndDate;
	
	@Temporal(TemporalType.DATE)
	@Column(name="actualstartDT")
	private Date actualStartDT;
	
	@Temporal(TemporalType.DATE)
	@Column(name="actualendDT")
	private Date actualEndDT;
	
	@ManyToOne
	@JoinColumn(name="member_id")
	private Employee assignTo;
	@ManyToOne
	@JoinColumn(name="status_id")
	private SetupsValue taskStatus;
	@ManyToOne
	@JoinColumn(name="resolution_id")
	private SetupsValue taskResolution;
	@ManyToOne
	@JoinColumn(name="created_by")
	private CrmUser createdBy;
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="created_at")
	private Date createdAt;
	
	@OneToMany(cascade=CascadeType.ALL, mappedBy="task")
	private List<TaskComment> comments;
	
	
	public Task() {
		super();
	}
	
	public ApplicationConstant.TaskdurationUnit getDurationUnit() {
		return durationUnit;
	}

	public void setDurationUnit(ApplicationConstant.TaskdurationUnit durationUnit) {
		this.durationUnit = durationUnit;
	}

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getTaskName() {
		return taskName;
	}
	public void setTaskName(String taskName) {
		this.taskName = taskName;
	}
	public String getTaskDetail() {
		return taskDetail;
	}
	public void setTaskDetail(String taskDetail) {
		this.taskDetail = taskDetail;
	}
	public ProjectDetails getProjectId() {
		return projectId;
	}
	public void setProjectId(ProjectDetails projectId) {
		this.projectId = projectId;
	}
	public SetupsValue getPriorityId() {
		return priorityId;
	}
	public void setPriorityId(SetupsValue priorityId) {
		this.priorityId = priorityId;
	}
	public Boolean isMileStone() {
		return mileStone;
	}
	public void setMileStone(Boolean mileStone) {
		this.mileStone = mileStone;
	}
	public Integer getEstmDuration() {
		return estmDuration;
	}
	public void setEstmDuration(Integer estmDuration) {
		this.estmDuration = estmDuration;
	}
	public Date getEstmStarDate() {
		return estmStarDate;
	}
	public void setEstmStarDate(Date estmStarDate) {
		this.estmStarDate = estmStarDate;
	}
	public Date getEstmEndDate() {
		return estmEndDate;
	}
	public void setEstmEndDate(Date estmEndDate) {
		this.estmEndDate = estmEndDate;
	}
	public Date getActualStartDT() {
		return actualStartDT;
	}
	public void setActualStartDT(Date actualStartDT) {
		this.actualStartDT = actualStartDT;
	}
	public Date getActualEndDT() {
		return actualEndDT;
	}
	public void setActualEndDT(Date actualEndDT) {
		this.actualEndDT = actualEndDT;
	}
	public Employee getAssignTo() {
		return assignTo;
	}
	public void setAssignTo(Employee assignTo) {
		this.assignTo = assignTo;
	}
	public SetupsValue getTaskStatus() {
		return taskStatus;
	}
	public void setTaskStatus(SetupsValue taskStatus) {
		this.taskStatus = taskStatus;
	}
	public SetupsValue getTaskResolution() {
		return taskResolution;
	}
	public void setTaskResolution(SetupsValue taskResolution) {
		this.taskResolution = taskResolution;
	}
	public CrmUser getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(CrmUser createdBy) {
		this.createdBy = createdBy;
	}
	public Date getCreatedAt() {
		return createdAt;
	}
	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	
	
	public List<TaskComment> getComments() {
		return comments;
	}

	public void setComments(List<TaskComment> comments) {
		this.comments = comments;
	}

	@Override
	public String toString() {
		return "Task [id=" + id + "]";
	}	

	

}
